class Solution:
    def removeDuplicates(self, nums: list[int]) -> int:
        leng = len(nums)
        flag = 0
        for i in range(leng):
            if nums[i] != nums[flag]:
                flag += 1
                nums[flag] = nums[i]
        return flag + 1


def PrintNum(n, cnt):
    print(n[:cnt])

if __name__ == '__main__':
    s = Solution()
    n = [1,1,2]
    PrintNum(n, s.removeDuplicates(n))
    n = [0,0,1,1,1,2,2,3,3,4]
    PrintNum(n, s.removeDuplicates(n))